package mo.tags.hash;

import java.util.LinkedList;
import java.util.Queue;

public class L3 {

    public int lengthOfLongestSubstring(String s) {
        int max = 0;
        Queue<Character> queue = new LinkedList<>();
        for (char c : s.toCharArray()) {
            if (queue.contains(c)) {
                max = Math.max(max, queue.size());
                while (!queue.isEmpty()) {
                    if (queue.poll() == c) {
                        break;
                    }
                }
            }
            queue.add(c);
        }
        return Math.max(max, queue.size());
    }


    public static void main(String[] args) {
        L3 test = new L3();
        System.out.println(test.lengthOfLongestSubstring("tmmzasnt"));
    }

}
